<template>
  <div class="box">
    <h2>2子组件</h2>
    值：<label>{{$store.state.count}}</label>
    <br>
    <button @click="sunCount(1)">值 -1</button>
    <button @click="sunCount(5)">值 -5</button>
  </div>
</template>

<script>
export default {
  methods: {
    sunCount (n) {
      this.$store.commit('countSub', n)
    }
  }
}
</script>

<style>
.box{
    border: 3px solid #ccc;
    width: 400px;
    padding: 10px;
    margin: 20px;
  }
  h2{
    margin-top: 10px;
  }
</style>
